package main;

import java.io.Serializable;

/**
 * A contact that has a first name, last name, street address, zip code, email
 * address, phone number, and any notes.
 * 
 * @author Michael
 */
public class Contact implements Comparable<Contact>, Serializable {

    private String notes;
    private String firstName;
    private String lastName;
    private String streetAddress;
    private String emailAddress;
    private String zipCode;
    private String phoneNumber;

    /**
     * Constructor that sets the values of the Contact
     * 
     * @param firstName
     * @param lastName
     * @param streetAddress
     * @param emailAddress
     * @param phoneNumber
     * @param notes
     */
    public Contact(String firstName, String lastName, String streetAddress,
            String zipCode, String emailAddress, String phoneNumber,
            String notes) {
        this.firstName = firstName;
        this.lastName = lastName;
        this.streetAddress = streetAddress;
        this.zipCode = zipCode;
        this.emailAddress = emailAddress;
        this.phoneNumber = phoneNumber;
        this.notes = notes;
    }

    /**
     * @return the firstName
     */
    public String getFirstName() {
        return firstName;
    }

    /**
     * @return the lastName
     */
    public String getLastName() {
        return lastName;
    }

    /**
     * @return the zip code
     */
    public String getZipCode() {
        return zipCode;
    }

    /**
     * @return the emailAddress
     */
    public String getEmailAddress() {
        return emailAddress;
    }

    /**
     * @return streetAddress
     */
    public String getStreetAddress() {
        return streetAddress;
    }

    /**
     * @return phoneNumber
     */
    public String getPhoneNumber() {
        return phoneNumber;
    }

    /**
     * @return notes
     */
    public String getNotes() {
        return notes;
    }

    /**
     * @return returns a String version of the Contact
     */
    public String toString() {
        String contactString = firstName + " " + lastName + "\n"
                + emailAddress + "\n" + phoneNumber + "\n"
                + streetAddress + " " + zipCode;
        if (notes.equals("")) {
            return contactString;
        } else {
            return contactString + "\n" + notes;
        }
    }

    /**
     * Returns -1 if this contact comes before, alphabetically 
     * Returns +1 if this contact comes after, alphabetically 
     * Returns 0 if the names are the same
     */
    @Override
    public int compareTo(Contact contact) {
        int compare = this.getLastName().compareToIgnoreCase(
                contact.getLastName());
        if (compare == 0)
            compare = this.getFirstName().compareToIgnoreCase(
                    contact.getFirstName());
        return compare;
    }
}